﻿using System;
using System.Collections.Generic;
using ContractManager.Entity;
using Speed.Data;

namespace ContractManager.BLL.Business
{
    public static class ClsContractType
    {
        public static List<ContractType> SelectAll()
        {
            using (var db = Sys.NewDb())
            {
                return Data.Base.ContractType.Select(db);
            }
            
        }

        public static void Insert(ContractType capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Insert<ContractType>(capital);
            }
            
        }

        public static void Update(ContractType capital)
        {
            using (var db = Sys.NewDb())
            {
                db.Update<ContractType>(capital);
            }
            
        }

        public static ContractType SelectByPk(Int32 conTypId)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<ContractType>(string.Format("ConTypId={0}", conTypId));
            }
            
        }

        public static ContractType SelectByCode(string conTypCode)
        {
            using (var db = Sys.NewDb())
            {
                return db.SelectSingle<ContractType>(string.Format("ConTypCode='{0}'", conTypCode));
            }
            
        }

        public static int DeleteByPk(Int32 conTypId)
        {
            using (var db = Sys.NewDb())
            {
                return db.Delete<ContractType>(string.Format("ConTypId={0}", conTypId));
            }
            
        }
    }
}